#!/bin/bash

source wfdb-hadoop-configuration.sh
wfdb-config --version 2>/dev/null
if [ ${?} != "0"  ] ; then
    #echo "The toolbox is not installed. Downloading the WFDB Toolbox..."
    unzip wfdb-app-toolbox-0-9-6-1.zip
    if [ "$?" != "0" ]
	then
	wget http://physionet.org/physiotools/matlab/wfdb-app-matlab/wfdb-app-toolbox-0-9-6-1.zip
    fi
    mv mcode ${DATA_DIR}/mcode
    sudo chmod a+x -R ${DATA_DIR}/mcode/
    sudo chmod a+r -R ${DATA_DIR}/mcode/
fi

export LD_LIBRARY_PATH=${DATA_DIR}/mcode/nativelibs/linux-amd64/lib64/:$LD_LIBRARY_PATH
export PATH=${DATA_DIR}/mcode/nativelibs/linux-amd64/lib64/:$PATH